﻿using BasicInformation.API.Application.Command.OwnerCommand;
using BasicInformation.Infrastructure.Interface;
using MediatR;

namespace BasicInformation.API.Application.CommandHandler.OwnerCommandHandler
{
    public class OwnerDeleteCommandHandler : IRequestHandler<OwnerDeleteCommand, int>
    {
        private readonly IOwnerRepository ownerRepository;
public OwnerDeleteCommandHandler(IOwnerRepository ownerRepository)
        {
            this.ownerRepository = ownerRepository;
        }

        public async Task<int> Handle(OwnerDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await ownerRepository.Get(request.Id);
            info.IsDel=true;
            return  await ownerRepository.Update(info);
        }   
    }
}
